import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from module_admin.annotation.pydantic_annotation import as_query


class FutureDailyQuoteModel(BaseModel):
    """
    期货日线行情表对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='行情id')
    code: Optional[str] = Field(default=None, description='期货代码')
    date: Optional[datetime.date] = Field(default=None, description='交易日期')
    open: Optional[float] = Field(default=None, description='开盘价')
    high: Optional[float] = Field(default=None, description='最高价')
    low: Optional[float] = Field(default=None, description='最低价')
    close: Optional[float] = Field(default=None, description='收盘价')
    volume: Optional[int] = Field(default=0, description='成交量')
    hold: Optional[int] = Field(default=0, description='持仓量')
    settle: Optional[float] = Field(default=None, description='结算价')


@as_query
class FutureDailyQuoteQueryModel(FutureDailyQuoteModel):
    """
    期货日线行情管理不分页查询模型
    """

    begin_date: Optional[str] = Field(default=None, description='开始日期')
    end_date: Optional[str] = Field(default=None, description='结束日期')


@as_query
class FutureDailyQuotePageQueryModel(FutureDailyQuoteQueryModel):
    """
    期货日线行情管理分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteFutureDailyQuoteModel(BaseModel):
    """
    删除期货日线行情模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    quote_ids: str = Field(description='需要删除的行情主键')